/**
 *
 */
import Util;
import OpenApi;
import OpenApiUtil;
import EndpointUtil;

extends OpenApi;

init(config: OpenApi.Config){
  super(config);
  @endpointRule = 'central';
  
@endpointMap = {
    cn-beijing = 'openanalytics.cn-beijing.aliyuncs.com',
    cn-zhangjiakou = 'openanalytics.cn-zhangjiakou.aliyuncs.com',
    cn-hangzhou = 'openanalytics.cn-hangzhou.aliyuncs.com',
    cn-shanghai = 'openanalytics.cn-shanghai.aliyuncs.com',
    cn-shenzhen = 'openanalytics.cn-shenzhen.aliyuncs.com',
    cn-hongkong = 'openanalytics.cn-hongkong.aliyuncs.com',
    ap-southeast-1 = 'openanalytics.ap-southeast-1.aliyuncs.com',
    ap-southeast-2 = 'datalakeanalytics.ap-southeast-2.aliyuncs.com',
    ap-southeast-3 = 'openanalytics.ap-southeast-3.aliyuncs.com',
    ap-northeast-1 = 'datalakeanalytics.ap-northeast-1.aliyuncs.com',
    eu-west-1 = 'openanalytics.eu-west-1.aliyuncs.com',
    us-west-1 = 'openanalytics.us-west-1.aliyuncs.com',
    us-east-1 = 'datalakeanalytics.us-east-1.aliyuncs.com',
    eu-central-1 = 'datalakeanalytics.eu-central-1.aliyuncs.com',
    ap-south-1 = 'openanalytics.ap-south-1.aliyuncs.com',
    ap-northeast-2-pop = 'openanalytics.ap-northeast-1.aliyuncs.com',
    ap-southeast-5 = 'openanalytics.ap-southeast-5.aliyuncs.com',
    cn-beijing-finance-1 = 'openanalytics.aliyuncs.com',
    cn-beijing-finance-pop = 'openanalytics.aliyuncs.com',
    cn-beijing-gov-1 = 'openanalytics.aliyuncs.com',
    cn-beijing-nu16-b01 = 'openanalytics.aliyuncs.com',
    cn-chengdu = 'openanalytics.aliyuncs.com',
    cn-edge-1 = 'openanalytics.aliyuncs.com',
    cn-fujian = 'openanalytics.aliyuncs.com',
    cn-haidian-cm12-c01 = 'openanalytics.aliyuncs.com',
    cn-hangzhou-bj-b01 = 'openanalytics.aliyuncs.com',
    cn-hangzhou-finance = 'openanalytics.aliyuncs.com',
    cn-hangzhou-internal-prod-1 = 'openanalytics.aliyuncs.com',
    cn-hangzhou-internal-test-1 = 'openanalytics.aliyuncs.com',
    cn-hangzhou-internal-test-2 = 'openanalytics.aliyuncs.com',
    cn-hangzhou-internal-test-3 = 'openanalytics.aliyuncs.com',
    cn-hangzhou-test-306 = 'openanalytics.aliyuncs.com',
    cn-hongkong-finance-pop = 'openanalytics.aliyuncs.com',
    cn-huhehaote = 'openanalytics.cn-huhehaote.aliyuncs.com',
    cn-north-2-gov-1 = 'openanalytics.aliyuncs.com',
    cn-qingdao = 'openanalytics.cn-qingdao.aliyuncs.com',
    cn-qingdao-nebula = 'openanalytics.aliyuncs.com',
    cn-shanghai-et15-b01 = 'openanalytics.aliyuncs.com',
    cn-shanghai-et2-b01 = 'openanalytics.aliyuncs.com',
    cn-shanghai-finance-1 = 'openanalytics.aliyuncs.com',
    cn-shanghai-inner = 'openanalytics.aliyuncs.com',
    cn-shanghai-internal-test-1 = 'openanalytics.aliyuncs.com',
    cn-shenzhen-finance-1 = 'openanalytics.aliyuncs.com',
    cn-shenzhen-inner = 'openanalytics.aliyuncs.com',
    cn-shenzhen-st4-d01 = 'openanalytics.aliyuncs.com',
    cn-shenzhen-su18-b01 = 'openanalytics.aliyuncs.com',
    cn-wuhan = 'openanalytics.aliyuncs.com',
    cn-yushanfang = 'openanalytics.aliyuncs.com',
    cn-zhangbei-na61-b01 = 'openanalytics.aliyuncs.com',
    cn-zhangjiakou-na62-a01 = 'openanalytics.aliyuncs.com',
    cn-zhengzhou-nebula-1 = 'openanalytics.aliyuncs.com',
    eu-west-1-oxs = 'openanalytics.ap-northeast-1.aliyuncs.com',
    me-east-1 = 'openanalytics.me-east-1.aliyuncs.com',
    rus-west-1-pop = 'openanalytics.ap-northeast-1.aliyuncs.com',
  };

  checkConfig(config);
  @endpoint = getEndpoint('openanalytics-open', @regionId, @endpointRule, @network, @suffix, @endpointMap, @endpoint);
}

function getEndpoint(productId: string, regionId: string, endpointRule: string, network: string, suffix: string, endpointMap: map[string]string, endpoint: string) throws: string{
  if (!Util.empty(endpoint)) {
    return endpoint;
  }

  if (!Util.isUnset(endpointMap) && !Util.empty(endpointMap[regionId])) {
    return endpointMap[regionId];
  }
  return EndpointUtil.getEndpointRules(productId, regionId, endpointRule, network, suffix);
}
model AddPartitionsRequest {
  partition?: [ 
    {
      dbName?: string(name='DbName', description='数据库名称'),
      parameters?: map[string]string(name='Parameters', description='分区属性'),
      storageDescriptor?: {
        col?: [ 
          {
            comment?: string(name='Comment', description='列注释'),
            name?: string(name='Name', description='列名'),
            type?: string(name='Type', description='列类型'),
          }
        ](name='Col', description='表的列信息'),
        inputFormat?: string(name='InputFormat', description='表的 inputFormat'),
        location?: string(name='Location', description='表路径'),
        outputFormat?: string(name='OutputFormat', description='表的 outputFormat'),
        parameters?: map[string]string(name='Parameters', description='StorageDescriptor 的属性'),
        serDeInfo?: {
          name?: string(name='Name', description='SerDe 的名字'),
          parameters?: map[string]string(name='Parameters', description='SerDe 的'),
          serializationLib?: string(name='SerializationLib', description='SerDe 的 serializationLib 信息'),
        }(name='SerDeInfo', description='表的 serDeInfo'),
      }(name='StorageDescriptor', description='分区的 StorageDescriptor '),
      tableName?: string(name='TableName', description='表名'),
      values?: [ string ](name='Values', description='需要添加的分区'),
    }
  ](name='Partition', description='添加的分区'),
}

model AddPartitionsShrinkRequest {
  partitionShrink?: string(name='Partition', description='添加的分区'),
}

model AddPartitionsResponseBody = {
  code?: string(name='Code', description='如果后端处理出现错误，则表示错误的类型'),
  data?: long(name='Data', description='成功添加的分区个数'),
  message?: string(name='Message', description='如果后端处理出现错误，则表示错误的信息'),
  requestId?: string(name='RequestId', description='请求的 ID'),
  success?: boolean(name='Success', description='标识本次请求是否成功'),
}

model AddPartitionsResponse = {
  headers: map[string]string(name='headers'),
  body: AddPartitionsResponseBody(name='body'),
}

async function addPartitionsWithOptions(tmpReq: AddPartitionsRequest, runtime: Util.RuntimeOptions): AddPartitionsResponse {
  Util.validateModel(tmpReq);
  var request = new AddPartitionsShrinkRequest{};
  OpenApiUtil.convert(tmpReq, request);
  if (!Util.isUnset(tmpReq.partition)) {
    request.partitionShrink = OpenApiUtil.arrayToStringWithSpecifiedStyle(tmpReq.partition, 'Partition', 'json');
  }
  var query = {};
  query["Partition"] = request.partitionShrink;
  var req = new OpenApi.OpenApiRequest{ 
    query = OpenApiUtil.query(query),
    body = Util.toMap(request),
  };
  var params = new OpenApi.Params{
    action = 'AddPartitions',
    version = '2020-09-28',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'json',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

async function addPartitions(request: AddPartitionsRequest): AddPartitionsResponse {
  var runtime = new Util.RuntimeOptions{};
  return addPartitionsWithOptions(request, runtime);
}

model AlterDatabaseRequest {
  name?: string(name='Name', description='修改数据库的新名称'),
  description?: string(name='Description', description='数据库描述'),
  locationUri?: string(name='LocationUri', description='数据库的'),
  oldDbName?: string(name='OldDbName', description='修改数据库的旧名称'),
  parameters?: map[string]string(name='Parameters', description='数据库的'),
}

model AlterDatabaseShrinkRequest {
  name?: string(name='Name', description='修改数据库的新名称'),
  description?: string(name='Description', description='数据库描述'),
  locationUri?: string(name='LocationUri', description='数据库的'),
  oldDbName?: string(name='OldDbName', description='修改数据库的旧名称'),
  parametersShrink?: string(name='Parameters', description='数据库的'),
}

model AlterDatabaseResponseBody = {
  code?: string(name='Code', description='如果后端处理出现错误，则表示错误的类型'),
  data?: string(name='Data', description='null'),
  message?: string(name='Message', description='如果后端处理出现错误，则表示错误的信息'),
  requestId?: string(name='RequestId', description='请求的 ID'),
  success?: boolean(name='Success', description='标识本次请求是否成功'),
}

model AlterDatabaseResponse = {
  headers: map[string]string(name='headers'),
  body: AlterDatabaseResponseBody(name='body'),
}

async function alterDatabaseWithOptions(tmpReq: AlterDatabaseRequest, runtime: Util.RuntimeOptions): AlterDatabaseResponse {
  Util.validateModel(tmpReq);
  var request = new AlterDatabaseShrinkRequest{};
  OpenApiUtil.convert(tmpReq, request);
  if (!Util.isUnset(tmpReq.parameters)) {
    request.parametersShrink = OpenApiUtil.arrayToStringWithSpecifiedStyle(tmpReq.parameters, 'Parameters', 'json');
  }
  var query = {};
  query["Name"] = request.name;
  query["Description"] = request.description;
  query["LocationUri"] = request.locationUri;
  query["OldDbName"] = request.oldDbName;
  query["Parameters"] = request.parametersShrink;
  var req = new OpenApi.OpenApiRequest{ 
    query = OpenApiUtil.query(query),
    body = Util.toMap(request),
  };
  var params = new OpenApi.Params{
    action = 'AlterDatabase',
    version = '2020-09-28',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'json',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

async function alterDatabase(request: AlterDatabaseRequest): AlterDatabaseResponse {
  var runtime = new Util.RuntimeOptions{};
  return alterDatabaseWithOptions(request, runtime);
}

model AlterTableRequest {
  oldDbName?: string(name='OldDbName', description='旧数据库名称'),
  oldTableName?: string(name='OldTableName', description='旧表名'),
  newDbName?: string(name='NewDbName', description='新的数据库名'),
  newTableName?: string(name='NewTableName', description='新表名'),
  parameters?: map[string]string(name='Parameters', description='表的新参数'),
  col?: [ 
    {
      comment?: string(name='Comment', description='列注释'),
      name?: string(name='Name', description='列名称'),
      type?: string(name='Type', description='列类型'),
    }
  ](name='Col', description='表的列信息'),
}

model AlterTableShrinkRequest {
  oldDbName?: string(name='OldDbName', description='旧数据库名称'),
  oldTableName?: string(name='OldTableName', description='旧表名'),
  newDbName?: string(name='NewDbName', description='新的数据库名'),
  newTableName?: string(name='NewTableName', description='新表名'),
  parametersShrink?: string(name='Parameters', description='表的新参数'),
  colShrink?: string(name='Col', description='表的列信息'),
}

model AlterTableResponseBody = {
  code?: string(name='Code', description='如果后端处理出现错误，则表示错误的类型'),
  data?: boolean(name='Data', description='修改表是否成功'),
  message?: string(name='Message', description='如果后端处理出现错误，则表示错误的信息'),
  requestId?: string(name='RequestId', description='请求的 ID'),
  success?: boolean(name='Success', description='标识本次请求是否成功'),
}

model AlterTableResponse = {
  headers: map[string]string(name='headers'),
  body: AlterTableResponseBody(name='body'),
}

async function alterTableWithOptions(tmpReq: AlterTableRequest, runtime: Util.RuntimeOptions): AlterTableResponse {
  Util.validateModel(tmpReq);
  var request = new AlterTableShrinkRequest{};
  OpenApiUtil.convert(tmpReq, request);
  if (!Util.isUnset(tmpReq.parameters)) {
    request.parametersShrink = OpenApiUtil.arrayToStringWithSpecifiedStyle(tmpReq.parameters, 'Parameters', 'json');
  }
  if (!Util.isUnset(tmpReq.col)) {
    request.colShrink = OpenApiUtil.arrayToStringWithSpecifiedStyle(tmpReq.col, 'Col', 'json');
  }
  var query = {};
  query["OldDbName"] = request.oldDbName;
  query["OldTableName"] = request.oldTableName;
  query["NewDbName"] = request.newDbName;
  query["NewTableName"] = request.newTableName;
  query["Parameters"] = request.parametersShrink;
  query["Col"] = request.colShrink;
  var req = new OpenApi.OpenApiRequest{ 
    query = OpenApiUtil.query(query),
    body = Util.toMap(request),
  };
  var params = new OpenApi.Params{
    action = 'AlterTable',
    version = '2020-09-28',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'json',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

async function alterTable(request: AlterTableRequest): AlterTableResponse {
  var runtime = new Util.RuntimeOptions{};
  return alterTableWithOptions(request, runtime);
}

model CreateDatabaseRequest {
  name?: string(name='Name', description='创建数据库的名字'),
  description?: string(name='Description', description='数据库描述'),
  locationUri?: string(name='LocationUri', description='数据库的 location'),
  parameters?: map[string]string(name='Parameters', description='数据库属性'),
}

model CreateDatabaseShrinkRequest {
  name?: string(name='Name', description='创建数据库的名字'),
  description?: string(name='Description', description='数据库描述'),
  locationUri?: string(name='LocationUri', description='数据库的 location'),
  parametersShrink?: string(name='Parameters', description='数据库属性'),
}

model CreateDatabaseResponseBody = {
  code?: string(name='Code', description='如果后端处理出现错误，则表示错误的类型'),
  data?: long(name='Data', description='成功创建库的库ID'),
  message?: string(name='Message', description='如果后端处理出现错误，则表示错误的信息'),
  requestId?: string(name='RequestId', description='请求的 ID'),
  success?: boolean(name='Success', description='标识本次请求是否成功'),
}

model CreateDatabaseResponse = {
  headers: map[string]string(name='headers'),
  body: CreateDatabaseResponseBody(name='body'),
}

async function createDatabaseWithOptions(tmpReq: CreateDatabaseRequest, runtime: Util.RuntimeOptions): CreateDatabaseResponse {
  Util.validateModel(tmpReq);
  var request = new CreateDatabaseShrinkRequest{};
  OpenApiUtil.convert(tmpReq, request);
  if (!Util.isUnset(tmpReq.parameters)) {
    request.parametersShrink = OpenApiUtil.arrayToStringWithSpecifiedStyle(tmpReq.parameters, 'Parameters', 'json');
  }
  var query = {};
  query["Name"] = request.name;
  query["Description"] = request.description;
  query["LocationUri"] = request.locationUri;
  query["Parameters"] = request.parametersShrink;
  var req = new OpenApi.OpenApiRequest{ 
    query = OpenApiUtil.query(query),
    body = Util.toMap(request),
  };
  var params = new OpenApi.Params{
    action = 'CreateDatabase',
    version = '2020-09-28',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'json',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

async function createDatabase(request: CreateDatabaseRequest): CreateDatabaseResponse {
  var runtime = new Util.RuntimeOptions{};
  return createDatabaseWithOptions(request, runtime);
}

model CreateTableRequest {
  dbName?: string(name='DbName', description='创建表所在数据库的名称'),
  tableName?: string(name='TableName', description='创建表的名称'),
  partitionKeys?: [ 
    {
      comment?: string(name='Comment', description='分区字段的注释'),
      name?: string(name='Name', description='分区字段的列名'),
      type?: string(name='Type', description='分区字段的类型'),
    }
  ](name='PartitionKeys', description='分区字段，可选'),
  parameters?: map[string]string(name='Parameters', description='表属性'),
  storageDescriptor?: {
    cols?: [ 
      {
        comment?: string(name='Comment', description='列注释'),
        name?: string(name='Name', description='列名'),
        type?: string(name='Type', description='列类型'),
      }
    ](name='Cols', description='表的列信息'),
    inputFormat?: string(name='InputFormat', description='表的 inputFormat'),
    location?: string(name='Location', description='表路径'),
    outputFormat?: string(name='OutputFormat', description='表的 outputFormat'),
    parameters?: map[string]string(name='Parameters', description='StorageDescriptor 的属性'),
    serDeInfo?: {
      name?: string(name='Name', description='SerDe 的名字'),
      parameters?: map[string]string(name='Parameters', description='SerDe 的属性'),
      serializationLib?: string(name='SerializationLib', description='SerDe 的 serializationLib 信息'),
    }(name='SerDeInfo', description='表的 serDeInfo'),
  }(name='StorageDescriptor', description='storageDescriptorModel'),
  viewOriginalText?: string(name='ViewOriginalText', description='视图的原始 SQL'),
  viewExpandedText?: string(name='ViewExpandedText', description='视图的展开 SQL'),
  tableType?: string(name='TableType', description='表的类型'),
}

model CreateTableShrinkRequest {
  dbName?: string(name='DbName', description='创建表所在数据库的名称'),
  tableName?: string(name='TableName', description='创建表的名称'),
  partitionKeysShrink?: string(name='PartitionKeys', description='分区字段，可选'),
  parametersShrink?: string(name='Parameters', description='表属性'),
  storageDescriptorShrink?: string(name='StorageDescriptor', description='storageDescriptorModel'),
  viewOriginalText?: string(name='ViewOriginalText', description='视图的原始 SQL'),
  viewExpandedText?: string(name='ViewExpandedText', description='视图的展开 SQL'),
  tableType?: string(name='TableType', description='表的类型'),
}

model CreateTableResponseBody = {
  code?: string(name='Code', description='如果后端处理出现错误，则表示错误的类型'),
  data?: long(name='Data', description='创建成功的表 ID'),
  message?: string(name='Message', description='如果后端处理出现错误，则表示错误的信息'),
  requestId?: string(name='RequestId', description='请求的 ID'),
  success?: boolean(name='Success', description='标识本次请求是否成功'),
}

model CreateTableResponse = {
  headers: map[string]string(name='headers'),
  body: CreateTableResponseBody(name='body'),
}

async function createTableWithOptions(tmpReq: CreateTableRequest, runtime: Util.RuntimeOptions): CreateTableResponse {
  Util.validateModel(tmpReq);
  var request = new CreateTableShrinkRequest{};
  OpenApiUtil.convert(tmpReq, request);
  if (!Util.isUnset(tmpReq.partitionKeys)) {
    request.partitionKeysShrink = OpenApiUtil.arrayToStringWithSpecifiedStyle(tmpReq.partitionKeys, 'PartitionKeys', 'json');
  }
  if (!Util.isUnset(tmpReq.parameters)) {
    request.parametersShrink = OpenApiUtil.arrayToStringWithSpecifiedStyle(tmpReq.parameters, 'Parameters', 'json');
  }
  if (!Util.isUnset(tmpReq.storageDescriptor)) {
    request.storageDescriptorShrink = OpenApiUtil.arrayToStringWithSpecifiedStyle(tmpReq.storageDescriptor, 'StorageDescriptor', 'json');
  }
  var query = {};
  query["DbName"] = request.dbName;
  query["TableName"] = request.tableName;
  query["PartitionKeys"] = request.partitionKeysShrink;
  query["Parameters"] = request.parametersShrink;
  query["StorageDescriptor"] = request.storageDescriptorShrink;
  query["ViewOriginalText"] = request.viewOriginalText;
  query["ViewExpandedText"] = request.viewExpandedText;
  query["TableType"] = request.tableType;
  var req = new OpenApi.OpenApiRequest{ 
    query = OpenApiUtil.query(query),
    body = Util.toMap(request),
  };
  var params = new OpenApi.Params{
    action = 'CreateTable',
    version = '2020-09-28',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'json',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

async function createTable(request: CreateTableRequest): CreateTableResponse {
  var runtime = new Util.RuntimeOptions{};
  return createTableWithOptions(request, runtime);
}

model DropDatabaseRequest {
  name?: string(name='Name', description='需要删除的数据库名称'),
  cascade?: boolean(name='Cascade', description='如果设置为ture，那么数据库里面有表会先把表删除，再删除数据库；如果设置为false，那么数据库里面有表则不能删除数据库。'),
}

model DropDatabaseResponseBody = {
  code?: string(name='Code', description='如果后端处理出现错误，则表示错误的类型'),
  data?: string(name='Data', description='null'),
  message?: string(name='Message', description='如果后端处理出现错误，则表示错误的信息'),
  requestId?: string(name='RequestId', description='请求的 ID'),
  success?: boolean(name='Success', description='标识本次请求是否成功'),
}

model DropDatabaseResponse = {
  headers: map[string]string(name='headers'),
  body: DropDatabaseResponseBody(name='body'),
}

async function dropDatabaseWithOptions(request: DropDatabaseRequest, runtime: Util.RuntimeOptions): DropDatabaseResponse {
  Util.validateModel(request);
  var query = {};
  query["Name"] = request.name;
  query["Cascade"] = request.cascade;
  var req = new OpenApi.OpenApiRequest{ 
    query = OpenApiUtil.query(query),
    body = Util.toMap(request),
  };
  var params = new OpenApi.Params{
    action = 'DropDatabase',
    version = '2020-09-28',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'json',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

async function dropDatabase(request: DropDatabaseRequest): DropDatabaseResponse {
  var runtime = new Util.RuntimeOptions{};
  return dropDatabaseWithOptions(request, runtime);
}

model DropPartitionRequest {
  dbName?: string(name='DbName', description='数据库名称'),
  tableName?: string(name='TableName', description='表名'),
  partValues?: [ string ](name='PartValues', description='需要删除的分区'),
}

model DropPartitionShrinkRequest {
  dbName?: string(name='DbName', description='数据库名称'),
  tableName?: string(name='TableName', description='表名'),
  partValuesShrink?: string(name='PartValues', description='需要删除的分区'),
}

model DropPartitionResponseBody = {
  code?: string(name='Code', description='如果后端处理出现错误，则表示错误的类型'),
  data?: boolean(name='Data', description='删除分区是否成功'),
  message?: string(name='Message', description='如果后端处理出现错误，则表示错误的信息'),
  requestId?: string(name='RequestId', description='请求的 ID'),
  success?: boolean(name='Success', description='标识本次请求是否成功'),
}

model DropPartitionResponse = {
  headers: map[string]string(name='headers'),
  body: DropPartitionResponseBody(name='body'),
}

async function dropPartitionWithOptions(tmpReq: DropPartitionRequest, runtime: Util.RuntimeOptions): DropPartitionResponse {
  Util.validateModel(tmpReq);
  var request = new DropPartitionShrinkRequest{};
  OpenApiUtil.convert(tmpReq, request);
  if (!Util.isUnset(tmpReq.partValues)) {
    request.partValuesShrink = OpenApiUtil.arrayToStringWithSpecifiedStyle(tmpReq.partValues, 'PartValues', 'json');
  }
  var query = {};
  query["DbName"] = request.dbName;
  query["TableName"] = request.tableName;
  query["PartValues"] = request.partValuesShrink;
  var req = new OpenApi.OpenApiRequest{ 
    query = OpenApiUtil.query(query),
    body = Util.toMap(request),
  };
  var params = new OpenApi.Params{
    action = 'DropPartition',
    version = '2020-09-28',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'json',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

async function dropPartition(request: DropPartitionRequest): DropPartitionResponse {
  var runtime = new Util.RuntimeOptions{};
  return dropPartitionWithOptions(request, runtime);
}

model DropTableRequest {
  dbName?: string(name='DbName', description='数据库名称'),
  tableName?: string(name='TableName', description='表名称'),
}

model DropTableResponseBody = {
  code?: string(name='Code', description='如果后端处理出现错误，则表示错误的类型'),
  data?: boolean(name='Data', description='标记表是否删除成功'),
  message?: string(name='Message', description='如果后端处理出现错误，则表示错误的信息'),
  requestId?: string(name='RequestId', description='请求的 ID'),
  success?: boolean(name='Success', description='标识本次请求是否成功'),
}

model DropTableResponse = {
  headers: map[string]string(name='headers'),
  body: DropTableResponseBody(name='body'),
}

async function dropTableWithOptions(request: DropTableRequest, runtime: Util.RuntimeOptions): DropTableResponse {
  Util.validateModel(request);
  var query = {};
  query["DbName"] = request.dbName;
  query["TableName"] = request.tableName;
  var req = new OpenApi.OpenApiRequest{ 
    query = OpenApiUtil.query(query),
    body = Util.toMap(request),
  };
  var params = new OpenApi.Params{
    action = 'DropTable',
    version = '2020-09-28',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'json',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

async function dropTable(request: DropTableRequest): DropTableResponse {
  var runtime = new Util.RuntimeOptions{};
  return dropTableWithOptions(request, runtime);
}

model GetAllDatabasesResponseBody = {
  code?: string(name='Code', description='如果后端处理出现错误，则表示错误的类型'),
  data?: [ string ](name='Data', description='返回的数据库列表'),
  message?: string(name='Message', description='如果后端处理出现错误，则表示错误的信息'),
  requestId?: string(name='RequestId', description='请求的 ID'),
  success?: boolean(name='Success', description='标识本次请求是否成功'),
}

model GetAllDatabasesResponse = {
  headers: map[string]string(name='headers'),
  body: GetAllDatabasesResponseBody(name='body'),
}

async function getAllDatabasesWithOptions(runtime: Util.RuntimeOptions): GetAllDatabasesResponse {
  var req = new OpenApi.OpenApiRequest{};
  var params = new OpenApi.Params{
    action = 'GetAllDatabases',
    version = '2020-09-28',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'json',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

async function getAllDatabases(): GetAllDatabasesResponse {
  var runtime = new Util.RuntimeOptions{};
  return getAllDatabasesWithOptions(runtime);
}

model GetAllTablesRequest {
  dbName?: string(name='DbName', description='数据库名称'),
}

model GetAllTablesResponseBody = {
  code?: string(name='Code', description='如果后端处理出现错误，则表示错误的类型'),
  data?: [ string ](name='Data', description='请求数据库低下的所有表'),
  message?: string(name='Message', description='如果后端处理出现错误，则表示错误的信息'),
  requestId?: string(name='RequestId', description='请求的 ID'),
  success?: boolean(name='Success', description='标识本次请求是否成功'),
}

model GetAllTablesResponse = {
  headers: map[string]string(name='headers'),
  body: GetAllTablesResponseBody(name='body'),
}

async function getAllTablesWithOptions(request: GetAllTablesRequest, runtime: Util.RuntimeOptions): GetAllTablesResponse {
  Util.validateModel(request);
  var query = {};
  query["DbName"] = request.dbName;
  var req = new OpenApi.OpenApiRequest{ 
    query = OpenApiUtil.query(query),
    body = Util.toMap(request),
  };
  var params = new OpenApi.Params{
    action = 'GetAllTables',
    version = '2020-09-28',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'json',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

async function getAllTables(request: GetAllTablesRequest): GetAllTablesResponse {
  var runtime = new Util.RuntimeOptions{};
  return getAllTablesWithOptions(request, runtime);
}

model GetDatabaseRequest {
  name?: string(name='Name', description='数据库名称'),
}

model GetDatabaseResponseBody = {
  code?: string(name='Code', description='如果后端处理出现错误，则表示错误的类型'),
  databaseModel?: {
    description?: string(name='Description', description='数据库描述'),
    locationUri?: string(name='LocationUri', description='数据库地址'),
    name?: string(name='Name', description='数据库名称'),
    ownerName?: string(name='OwnerName', description='数据库所属 DLA userName'),
    parameters?: map[string]string(name='Parameters', description='数据库参数'),
    tenantId?: string(name='TenantId', description='数据库所属的阿里云UID'),
  }(name='DatabaseModel', description='返回的数据库结构'),
  message?: string(name='Message', description='如果后端处理出现错误，则表示错误的信息'),
  requestId?: string(name='RequestId', description='请求的 ID'),
  success?: boolean(name='Success', description='标识本次请求是否成功'),
}

model GetDatabaseResponse = {
  headers: map[string]string(name='headers'),
  body: GetDatabaseResponseBody(name='body'),
}

async function getDatabaseWithOptions(request: GetDatabaseRequest, runtime: Util.RuntimeOptions): GetDatabaseResponse {
  Util.validateModel(request);
  var query = {};
  query["Name"] = request.name;
  var req = new OpenApi.OpenApiRequest{ 
    query = OpenApiUtil.query(query),
    body = Util.toMap(request),
  };
  var params = new OpenApi.Params{
    action = 'GetDatabase',
    version = '2020-09-28',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'json',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

async function getDatabase(request: GetDatabaseRequest): GetDatabaseResponse {
  var runtime = new Util.RuntimeOptions{};
  return getDatabaseWithOptions(request, runtime);
}

model GetPartitionRequest {
  dbName?: string(name='DbName', description='数据库名称'),
  tableName?: string(name='TableName', description='表名'),
  values?: [ string ](name='Values', description='分区'),
}

model GetPartitionShrinkRequest {
  dbName?: string(name='DbName', description='数据库名称'),
  tableName?: string(name='TableName', description='表名'),
  valuesShrink?: string(name='Values', description='分区'),
}

model GetPartitionResponseBody = {
  code?: string(name='Code', description='如果后端处理出现错误，则表示错误的类型'),
  message?: string(name='Message', description='如果后端处理出现错误，则表示错误的信息'),
  partitionModel?: {
    createTime?: long(name='CreateTime', description='分区创建时间'),
    dbName?: string(name='DbName', description='数据库名称'),
    parameters?: map[string]string(name='Parameters', description='分区参数'),
    storageDescriptorModel?: {
      cols?: [ 
        {
          comment?: string(name='Comment', description='列注释'),
          name?: string(name='Name', description='列名'),
          type?: string(name='Type', description='列类型'),
        }
      ](name='Cols', description='表的列信息'),
      inputFormat?: string(name='InputFormat', description='表的InputFormat'),
      location?: string(name='Location', description='表的路径'),
      outputFormat?: string(name='OutputFormat', description='表的OutputFormat'),
      parameters?: map[string]string(name='Parameters', description='表的属性'),
      serDeInfoModel?: {
        name?: string(name='Name', description='SerDe 的名称'),
        parameters?: map[string]string(name='Parameters', description='SerDe 的属性'),
        serializationLib?: string(name='SerializationLib', description='SerDe 的 serializationLib'),
      }(name='SerDeInfoModel', description='表的 SerDe 信息'),
    }(name='StorageDescriptorModel', description='分区 SD'),
    tableName?: string(name='TableName', description='表名'),
    values?: [ string ](name='Values', description='分区信息'),
  }(name='PartitionModel', description='获取到的分区'),
  requestId?: string(name='RequestId', description='请求的 ID'),
  success?: boolean(name='Success', description='标识本次请求是否成功'),
}

model GetPartitionResponse = {
  headers: map[string]string(name='headers'),
  body: GetPartitionResponseBody(name='body'),
}

async function getPartitionWithOptions(tmpReq: GetPartitionRequest, runtime: Util.RuntimeOptions): GetPartitionResponse {
  Util.validateModel(tmpReq);
  var request = new GetPartitionShrinkRequest{};
  OpenApiUtil.convert(tmpReq, request);
  if (!Util.isUnset(tmpReq.values)) {
    request.valuesShrink = OpenApiUtil.arrayToStringWithSpecifiedStyle(tmpReq.values, 'Values', 'json');
  }
  var query = {};
  query["DbName"] = request.dbName;
  query["TableName"] = request.tableName;
  query["Values"] = request.valuesShrink;
  var req = new OpenApi.OpenApiRequest{ 
    query = OpenApiUtil.query(query),
    body = Util.toMap(request),
  };
  var params = new OpenApi.Params{
    action = 'GetPartition',
    version = '2020-09-28',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'json',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

async function getPartition(request: GetPartitionRequest): GetPartitionResponse {
  var runtime = new Util.RuntimeOptions{};
  return getPartitionWithOptions(request, runtime);
}

model GetPartitionsRequest {
  dbName?: string(name='DbName', description='数据库名'),
  tableName?: string(name='TableName', description='表名'),
  maxParts?: int32(name='MaxParts', description='获取多少分区'),
}

model GetPartitionsResponseBody = {
  code?: string(name='Code', description='如果后端处理出现错误，则表示错误的类型'),
  message?: string(name='Message', description='如果后端处理出现错误，则表示错误的信息'),
  partitions?: [ 
    {
      createTime?: long(name='CreateTime', description='分区创建时间'),
      dbName?: string(name='DbName', description='数据库名'),
      parameters?: map[string]string(name='Parameters', description='分区属性'),
      storageDescriptorModel?: {
        cols?: [ 
          {
            comment?: string(name='Comment', description='列注释'),
            name?: string(name='Name', description='列名'),
            type?: string(name='Type', description='列类型'),
          }
        ](name='Cols', description='表的列'),
        inputFormat?: string(name='InputFormat', description='表的InputFormat'),
        location?: string(name='Location', description='表的路径'),
        outputFormat?: string(name='OutputFormat', description='表的OutputFormat'),
        parameters?: map[string]string(name='Parameters', description='表属性'),
        serDeInfoModel?: {
          name?: string(name='Name', description='SerDe名称'),
          parameters?: map[string]string(name='Parameters', description='SerDe属性'),
          serializationLib?: string(name='SerializationLib', description='SerDe的serializationLib'),
        }(name='SerDeInfoModel', description='表的 SerDe 信息'),
      }(name='StorageDescriptorModel', description='分区的 SD 信息'),
      tableName?: string(name='TableName', description='表名'),
      values?: [ string ](name='Values', description='分区的值'),
    }
  ](name='Partitions', description='获取的分区'),
  requestId?: string(name='RequestId', description='请求的 ID'),
  success?: boolean(name='Success', description='标识本次请求是否成功'),
}

model GetPartitionsResponse = {
  headers: map[string]string(name='headers'),
  body: GetPartitionsResponseBody(name='body'),
}

async function getPartitionsWithOptions(request: GetPartitionsRequest, runtime: Util.RuntimeOptions): GetPartitionsResponse {
  Util.validateModel(request);
  var query = {};
  query["DbName"] = request.dbName;
  query["TableName"] = request.tableName;
  query["MaxParts"] = request.maxParts;
  var req = new OpenApi.OpenApiRequest{ 
    query = OpenApiUtil.query(query),
    body = Util.toMap(request),
  };
  var params = new OpenApi.Params{
    action = 'GetPartitions',
    version = '2020-09-28',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'json',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

async function getPartitions(request: GetPartitionsRequest): GetPartitionsResponse {
  var runtime = new Util.RuntimeOptions{};
  return getPartitionsWithOptions(request, runtime);
}

model GetTableRequest {
  dbName?: string(name='DbName', description='数据库名称'),
  tableName?: string(name='TableName', description='表名称'),
}

model GetTableResponseBody = {
  code?: string(name='Code', description='如果后端处理出现错误，则表示错误的类型'),
  message?: string(name='Message', description='如果后端处理出现错误，则表示错误的信息'),
  requestId?: string(name='RequestId', description='请求的 ID'),
  success?: boolean(name='Success', description='标识本次请求是否成功'),
  table?: {
    createTime?: long(name='CreateTime', description='表的创建时间'),
    dbName?: string(name='DbName', description='数据库名称'),
    lastAccessTime?: long(name='LastAccessTime', description='最后一次访问时间'),
    owner?: string(name='Owner', description='表的所属用户'),
    parameters?: map[string]string(name='Parameters', description='表属性'),
    partitionKeys?: [ 
      {
        comment?: string(name='Comment', description='分区注释'),
        name?: string(name='Name', description='分区名称'),
        type?: string(name='Type', description='分区类型'),
      }
    ](name='PartitionKeys', description='分区信息'),
    storageDescriptor?: {
      cols?: [ 
        {
          comment?: string(name='Comment', description='列注释'),
          name?: string(name='Name', description='列名称'),
          type?: string(name='Type', description='列类型'),
        }
      ](name='Cols', description='表的列信息'),
      inputFormat?: string(name='InputFormat', description='表的 inputFormat'),
      location?: string(name='Location', description='表路径'),
      outputFormat?: string(name='OutputFormat', description='表的 outputFormat'),
      parameters?: map[string]any(name='Parameters', description='SD 的属性'),
      serDeInfo?: {
        name?: string(name='Name', description='SerDe 的名称'),
        parameters?: map[string]string(name='Parameters', description='SerDe 的属性'),
        serializationLib?: string(name='SerializationLib', description='SerDe 的 serializationLib'),
      }(name='SerDeInfo', description='表的 SerDe 信息'),
    }(name='StorageDescriptor', description='表的 sd 信息'),
    tableName?: string(name='TableName', description='表的名称'),
    tableType?: string(name='TableType', description='表的类型'),
    viewExpandedText?: string(name='ViewExpandedText', description='如果表是视图，则存储扩展视图SQL'),
    viewOriginalText?: string(name='ViewOriginalText', description='如果表是视图，则存储原生视图SQL'),
  }(name='Table', description='获取的表信息'),
}

model GetTableResponse = {
  headers: map[string]string(name='headers'),
  body: GetTableResponseBody(name='body'),
}

async function getTableWithOptions(request: GetTableRequest, runtime: Util.RuntimeOptions): GetTableResponse {
  Util.validateModel(request);
  var query = {};
  query["DbName"] = request.dbName;
  query["TableName"] = request.tableName;
  var req = new OpenApi.OpenApiRequest{ 
    query = OpenApiUtil.query(query),
    body = Util.toMap(request),
  };
  var params = new OpenApi.Params{
    action = 'GetTable',
    version = '2020-09-28',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'json',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

async function getTable(request: GetTableRequest): GetTableResponse {
  var runtime = new Util.RuntimeOptions{};
  return getTableWithOptions(request, runtime);
}

model GrantPrivilegesRequest {
  privilegeBag?: {
    hiveObjectPrivilege?: [ 
      {
        hiveObjectRef?: {
          dbName?: string(name='DbName', description='数据库名称'),
          hiveObjectType?: string(name='HiveObjectType', description='授权粒度'),
          tableName?: string(name='TableName', description='表名'),
        }(name='HiveObjectRef', description='HiveObjectRef'),
        principalName?: string(name='PrincipalName', description='给谁授权'),
        principalType?: string(name='PrincipalType', description='授权类型，只能为 USER'),
        privilegeGrantInfo?: {
          grantOption?: boolean(name='GrantOption', description='权限是否可以传递'),
          grantor?: string(name='Grantor', description='授权者'),
          principalType?: string(name='PrincipalType', description='授权者的类型，只能为 USER'),
          privilege?: string(name='Privilege', description='权限'),
        }(name='PrivilegeGrantInfo', description='授权者的信息'),
      }
    ](name='HiveObjectPrivilege', description='权限信息'),
  }(name='PrivilegeBag', description='权限信息'),
}

model GrantPrivilegesShrinkRequest {
  privilegeBagShrink?: string(name='PrivilegeBag', description='权限信息'),
}

model GrantPrivilegesResponseBody = {
  code?: string(name='Code', description='如果后端处理出现错误，则表示错误的类型'),
  data?: boolean(name='Data', description='授权是否成功'),
  message?: string(name='Message', description='如果后端处理出现错误，则表示错误的信息'),
  requestId?: string(name='RequestId', description='请求的 ID'),
  success?: boolean(name='Success', description='标识本次请求是否成功'),
}

model GrantPrivilegesResponse = {
  headers: map[string]string(name='headers'),
  body: GrantPrivilegesResponseBody(name='body'),
}

async function grantPrivilegesWithOptions(tmpReq: GrantPrivilegesRequest, runtime: Util.RuntimeOptions): GrantPrivilegesResponse {
  Util.validateModel(tmpReq);
  var request = new GrantPrivilegesShrinkRequest{};
  OpenApiUtil.convert(tmpReq, request);
  if (!Util.isUnset(tmpReq.privilegeBag)) {
    request.privilegeBagShrink = OpenApiUtil.arrayToStringWithSpecifiedStyle(tmpReq.privilegeBag, 'PrivilegeBag', 'json');
  }
  var query = {};
  query["PrivilegeBag"] = request.privilegeBagShrink;
  var req = new OpenApi.OpenApiRequest{ 
    query = OpenApiUtil.query(query),
    body = Util.toMap(request),
  };
  var params = new OpenApi.Params{
    action = 'GrantPrivileges',
    version = '2020-09-28',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'json',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

async function grantPrivileges(request: GrantPrivilegesRequest): GrantPrivilegesResponse {
  var runtime = new Util.RuntimeOptions{};
  return grantPrivilegesWithOptions(request, runtime);
}

model RevokePrivilegesRequest {
  privilegeBag?: {
    hiveObjectPrivilege?: [ 
      {
        hiveObjectRef?: {
          dbName?: string(name='DbName', description='数据库名称'),
          hiveObjectType?: string(name='HiveObjectType', description='授权粒度'),
          tableName?: string(name='TableName', description='表名'),
        }(name='HiveObjectRef', description='HiveObjectRef'),
        principalName?: string(name='PrincipalName', description='给谁授权'),
        principalType?: string(name='PrincipalType', description='授权类型，只能为 USER'),
        privilegeGrantInfo?: {
          grantOption?: boolean(name='GrantOption', description='权限是否可以传递'),
          grantor?: string(name='Grantor', description='授权者'),
          principalType?: string(name='PrincipalType', description='授权者的类型，只能为 USER'),
          privilege?: string(name='Privilege', description='权限'),
        }(name='PrivilegeGrantInfo', description='授权者的信息'),
      }
    ](name='HiveObjectPrivilege', description='权限信息'),
  }(name='PrivilegeBag', description='权限信息'),
}

model RevokePrivilegesShrinkRequest {
  privilegeBagShrink?: string(name='PrivilegeBag', description='权限信息'),
}

model RevokePrivilegesResponseBody = {
  code?: string(name='Code', description='如果后端处理出现错误，则表示错误的类型'),
  data?: boolean(name='Data', description='取消权限是否成功'),
  message?: string(name='Message', description='如果后端处理出现错误，则表示错误的信息'),
  requestId?: string(name='RequestId', description='请求的 ID'),
  success?: boolean(name='Success', description='标识本次请求是否成功'),
}

model RevokePrivilegesResponse = {
  headers: map[string]string(name='headers'),
  body: RevokePrivilegesResponseBody(name='body'),
}

async function revokePrivilegesWithOptions(tmpReq: RevokePrivilegesRequest, runtime: Util.RuntimeOptions): RevokePrivilegesResponse {
  Util.validateModel(tmpReq);
  var request = new RevokePrivilegesShrinkRequest{};
  OpenApiUtil.convert(tmpReq, request);
  if (!Util.isUnset(tmpReq.privilegeBag)) {
    request.privilegeBagShrink = OpenApiUtil.arrayToStringWithSpecifiedStyle(tmpReq.privilegeBag, 'PrivilegeBag', 'json');
  }
  var query = {};
  query["PrivilegeBag"] = request.privilegeBagShrink;
  var req = new OpenApi.OpenApiRequest{ 
    query = OpenApiUtil.query(query),
    body = Util.toMap(request),
  };
  var params = new OpenApi.Params{
    action = 'RevokePrivileges',
    version = '2020-09-28',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'json',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

async function revokePrivileges(request: RevokePrivilegesRequest): RevokePrivilegesResponse {
  var runtime = new Util.RuntimeOptions{};
  return revokePrivilegesWithOptions(request, runtime);
}

